

import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:xim/common/get_style_view.dart';
import 'package:xim/common/util/security.dart';
import 'package:xim/http/apis/gfs/gfs_api.dart';
import 'package:flutter/services.dart' show rootBundle;

class VideoViewH5Controller extends GetxStateMixinController<dynamic>{

  /// 文件Code
  final String fileCode;

  /// 用于解密的密钥
  final String plainKey;

  /// 文件下载地址
  String get fileDownLoadUri => GfsApi.getGfsFileDownloadPath(fileCode);

  VideoViewH5Controller(this.fileCode, this.plainKey);

  InAppWebViewController? webViewController;

  InAppWebViewSettings settings = InAppWebViewSettings(
      isInspectable: true,
      useOnDownloadStart: true,
      mediaPlaybackRequiresUserGesture: false,
      allowsInlineMediaPlayback: true,
      iframeAllow: "camera; microphone",
      iframeAllowFullscreen: true,
      allowFileAccessFromFileURLs: true,
      allowUniversalAccessFromFileURLs: true,
  );

  PullToRefreshController? pullToRefreshController;

  final GlobalKey webViewKey = GlobalKey();

  late String pageData;

  String decodeKey(String encodeKey){
    return SecurityUtility.aes.decryptAes(encryptedBase64Text: encodeKey, aseKey: plainKey);
  }

  @override
  Future dataInit() async {
    pageData = await rootBundle.loadString("assets/h5/video/index.html");
  }

}